package MathHomeWorkTest;

import java.util.Scanner;

/*
《九章算术》方法求最大公约数，最小公倍数
输入14和6。14-6=8 →8-6=2→6-2=4→4-2=2→2-2=0；2就为最大公约数。最小公倍数为14×6÷2=42。
 */
public class MathTest20 {
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int num = s.nextInt();
        int num1 = s.nextInt();
        int ji = num * num1;
        if(num < num1){       //比较大小，交换位置
            int temp = num;
            num = num1;
            num1 = temp;
        }
        while(true){
            num = num -num1; //8 //2
            if(num < num1){
                int temp = num;
                num = num1;
                num1 = temp;
            }
            if(num == num1){
                System.out.println("最大公因数为"+num);
                break;
            }
        }
        System.out.println("最小公倍数为"+(ji / num));

    }
}
